package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.feign.WxMiniQuestionClient;
import com.sc.nft.req.question.WxMiniQuestionPageReq;
import com.sc.nft.req.question.WxMiniQuestionReq;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.question.QuestionDetailsVO;
import com.sc.nft.vo.question.QuestionPageVO;
import com.sc.nft.vo.question.QuestionWebTypeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/wxMiniMall/question")
@Api(tags = "小程序常见问题")
public class WxMiniQuestionController{

    private final WxMiniQuestionClient wxMiniQuestionClient;

    /**
     * 小程序问题创建
     * @param request
     * @return
     */
    @PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "创建常见问题")
    @SysMemberLogin
    public Result createQuestion(@Valid @RequestBody WxMiniQuestionReq request) {
        return wxMiniQuestionClient.createQuestion(request);
    }


    /**
     * 小程序问题编辑
     * @param request
     * @return
     */
    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "编辑常见问题")
    @SysMemberLogin
    public Result updateQuestion(@Valid @RequestBody WxMiniQuestionReq request) {
        return wxMiniQuestionClient.updateQuestion(request);
    }

    /**
     * 小程序问题详情
     * @param request
     * @return
     */
    @PostMapping(value = "/details", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "常见问题详情")
    @SysMemberLogin
    public Result<QuestionDetailsVO> questionDetails(@RequestBody IdRequest request) {
        return wxMiniQuestionClient.questionDetails(request);
    }


    /**
     * 小程序问题列表
     * @param request
     * @return
     */
    @PostMapping(value = "/adminPage", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "小程序问题列表")
    @SysMemberLogin
    public PageResult<QuestionPageVO> adminPage(@RequestBody WxMiniQuestionPageReq request) {
        return wxMiniQuestionClient.adminPage(request);
    }


    /**
     * 删除常见问题
     * @param request
     * @return
     */
    @PostMapping(value = "/remove", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除常见问题")
    @SysMemberLogin
    public Result removeQuestion(@Valid @RequestBody IdRequest request) {
        return wxMiniQuestionClient.removeQuestion(request);
    }


}